package com.sgcc.operate.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.operate.domain.OActiStat;
import com.sgcc.operate.service.IOActiStatService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * 活动趋势统计Controller
 * 
 * @author sgcc
 * @date 2021-03-31
 */
@RestController
@RequestMapping("/actistat")
public class OActiStatController extends BaseController
{
    @Autowired
    private IOActiStatService oActiStatService;

    /**
     * 查询活动趋势统计列表
     */
    //@PreAuthorize(hasPermi = "operate:actistat:list")
    @GetMapping("/list")
    public TableDataInfo list(OActiStat oActiStat)
    {
        startPage();
        List<OActiStat> list = oActiStatService.selectOActiStatList(oActiStat);
        return getDataTable(list);
    }

    /**
     * 导出活动趋势统计列表
     */
    //@PreAuthorize(hasPermi = "operate:actistat:export")
    @Log(title = "活动趋势统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OActiStat oActiStat) throws IOException
    {
        List<OActiStat> list = oActiStatService.selectOActiStatList(oActiStat);
        ExcelUtil<OActiStat> util = new ExcelUtil<OActiStat>(OActiStat.class);
        util.exportExcel(response, list, "actistat");
    }

    /**
     * 获取活动趋势统计详细信息
     */
    //@PreAuthorize(hasPermi = "operate:actistat:query")
    @GetMapping(value = "/{statDate}")
    public AjaxResult getInfo(@PathVariable("statDate") String statDate)
    {
        return AjaxResult.success(oActiStatService.selectOActiStatById(statDate));
    }

    /**
     * 新增活动趋势统计
     */
    //@PreAuthorize(hasPermi = "operate:actistat:add")
    @Log(title = "活动趋势统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OActiStat oActiStat)
    {
        return toAjax(oActiStatService.insertOActiStat(oActiStat));
    }

    /**
     * 修改活动趋势统计
     */
    //@PreAuthorize(hasPermi = "operate:actistat:edit")
    @Log(title = "活动趋势统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OActiStat oActiStat)
    {
        return toAjax(oActiStatService.updateOActiStat(oActiStat));
    }

    /**
     * 删除活动趋势统计
     */
    //@PreAuthorize(hasPermi = "operate:actistat:remove")
    @Log(title = "活动趋势统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statDates}")
    public AjaxResult remove(@PathVariable String[] statDates)
    {
        return toAjax(oActiStatService.deleteOActiStatByIds(statDates));
    }

    @GetMapping("/middleStatistic")
    public AjaxResult middleStatistic(String actiId, String type, String dateRange){
        return oActiStatService.middleStatistic(actiId, type,dateRange);
    }


    @GetMapping("/leftDownStatistic")
    public AjaxResult leftDownStatistic(String actiId){
        return oActiStatService.leftDownStatistic(actiId);
    }

    @GetMapping("/rightDownStatistic")
    public AjaxResult rightDownStatistic(String actiId, String areaNo){
        return oActiStatService.rightDownStatistic(actiId, areaNo);
    }


}
